package com.example.topologicalsorting43;

import lombok.Getter;

import java.util.LinkedList;

/**
 * @description 图
 * @auther lijiewei
 * @date 2022/6/23 10:34
 */
@Getter
public class Graph {

    //顶点个数
    private int v;

    //邻接表
    private LinkedList<Integer>[] adj;

    public Graph(int v) {
        this.v = v;
        adj = new LinkedList[v];
        for (int i = 0; i < v; i++) {
            //初始化一个链表
            adj[i] = new LinkedList<>();
        }
    }

    /**
     * 边 s->t, s 先于 t
     * @return
     * @author lijiewei
     * @date   2022/6/23 10:43
     */
    public void addEdge(int s, int t) {
        adj[s].add(t);
    }

}
